package cn.edu.scau.cmi.liujianxun.client.fxUI.factory;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import cn.edu.scau.cmi.liujianxun.factory.*;
import cn.edu.scau.cmi.liujianxun.factory.insurance.Insurance;
import cn.edu.scau.cmi.liujianxun.simpleFactoryMethod.InsuranceFactory;
import cn.edu.scau.cmi.liujianxun.simpleFactoryMethod.insurance.BodyInjur;
import cn.edu.scau.cmi.liujianxun.simpleFactoryMethod.insurance.Collision;
import cn.edu.scau.cmi.liujianxun.simpleFactoryMethod.insurance.Comprehensive;
import cn.edu.scau.cmi.liujianxun.simpleFactoryMethod.insurance.PersonInjur;
import javafx.event.ActionEvent;
import javafx.scene.control.Label;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import javafx.scene.image.ImageView;

public class FactoryDemoController {
	@FXML
	private Label lbName;
	@FXML
	private Label lbNum;
	@FXML
	private ComboBox<String> cbBox;
	@FXML
	private TextArea textArea;
	@FXML
	private ImageView imageView;
	@FXML
	private Button bt;

	String[] s = {"司机受伤", "汽车损坏", "人员伤亡", "多种事故"};
	
	public FactoryDemoController() {
		
	}
	public void init() {
		cbBox.getItems().addAll(s);
	}
	
	public void btEvent() {
		String policy = cbBox.getValue();
		
		PolicyProducer pp = null;
		switch(policy)
		{
		case "司机受伤": pp = new BodyPolicy();break;
		case "汽车损坏": pp = new CollPolicy();break;
		case "人员伤亡": pp = new PersonPolicy();break;
		case "多种事故": pp = new ComPolicy();break;
		default : break;
		}
		
		Insurance i = pp.getInsurObj();
		String result = i.getInsurInfo();
		
		textArea.appendText(result + '\n');
	}
}
